{{extend 'layout.html'}}

<h2>Purdue Competitive Programming Class (2011 Edition)</h2>
<!-- <a href="/icypc/static/view1-full.png"><img src="/icypc/static/view1-small.png" align=right hspace=50></a> -->

See the course wiki page for <a href="http://www.bikmort.com/dokuwiki/icypc_instructions">instructions</a> on using
the ladder.
<br/>
<a href="/icypc/static/brackets-full-2011.png"><img src="/icypc/static/brackets-small-2011.png" align=right hspace=50></a>
<br/>

<h2>ICPYC Competition Ladder</h2>

<style type="text/css">
.va {
    vertical-align:middle;
    background:transparent;
    border-width:thin;
    border-color:black;
    border-style:solid;
}
</style>

<table class="va">
    <tr>
    <th class="va">Rank</th>
    <th class="va">Competitor</th>
    <th class="va">Wins</th>
    <th class="va">Losses</th>
    <th class="va">Challenge</th>
    </tr>
{{i = 0}}
{{for r in ladder:}}
    {{i += 1}}
    <tr>
    <td class="va">{{=i}}</td>
    <td class="va">{{=r[0]}}/{{=r[1]}}</td>
    <td class="va">{{=r[2]}}</td>
    <td class="va">{{=r[3]}}</td>
    <td class="va">
    {{if i > 1:}}
        {{=FORM(INPUT(_type="submit", _value="Challenge Up"), _action=URL('challenge'), hidden=dict(number=i, userid=r[0], player=r[1]))}}
    {{else:}}
        {{pass}}
    </td>
    </tr>
    {{pass}}
</table>
<br/>

<h2>Make a Challenge</h2>
{{if login:}}
    {{=cform.custom.begin}}
    <table>
    <tr><td>Your player script (e.g., hunter):</td><td>{{=cform.custom.widget.player}}</td></tr>
    </table>
    <p />{{=cform.custom.submit}}<br />
    <i>Note that your player script must be world executable and located in 
    a world readable top-level directory named "icypc" (e.g.,</i> <tt>~{{=login}}/icypc/hunter</tt><i>).</i><p />
    {{=cform.custom.end}}
{{else:}}
    <i>You must be logged in to make a challenge.</i><p />
{{pass}}
<br/>

{{matchCount = 0; matchLimit = 25}}
<h2>Individual Match Results (first {{=matchLimit}} only)</h2>

<table>
<tr><th>Match</th><th>Challenger (Red)</th><th>Result</th><th>Defender (Blue)</th><th>Time</th><th>Output</th></tr>
{{for m in match:}}
    {{if m.winner_color:}}
        {{matchCount = matchCount + 1}}
        {{if matchCount > matchLimit:}}
            {{break}}
        <tr>
        <td>{{=m.id}}</td>
        {{if m.winner_color == 'red':}}
            <td>{{=m.winner.name_user[0:15] + "/" + m.winner.name_player[0:15]}}</td>
            <td>&gt;</td>
            <td>{{=m.loser.name_user[0:15] + "/" + m.loser.name_player[0:15]}}</td>
        {{else:}}
            <td>{{=m.loser.name_user[0:15] + "/" + m.loser.name_player[0:15]}}</td>
            <td>&lt;</td>
            <td>{{=m.winner.name_user[0:15] + "/" + m.winner.name_player[0:15]}}</td>
            {{pass}}
        <td>{{=m.time}}</td>
        <td>{{=m.output}}</td>
        </tr>
        {{pass}}
    {{pass}}
</table>
<br/>

{{if competitor:}}
<h2>The Competitors</h2>
<table class="va">
<tr><th class="va">Competitor</th><th class="va">Status</th></tr>
{{for c in competitor:}}
    <tr>
    <td class="va">{{=c.name_user[0:10] + "/" + c.name_player[0:20]}}</td>
    <td class="va">{{=c.status}}</td>
    </tr>
    {{pass}}
</table>
<br/>
{{pass}}

{{if login:}}
<h2>Debugging Information</h2>

{{=BEAUTIFY(session)}}
{{pass}}
